<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>已办项目</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/templates/act/process.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form searchForm" action="">
    查询:
    <div class="layui-input-inline">
        <input style="width:200px;" type="text" name="prjName" placeholder="项目名称" autocomplete="off"
               class="layui-input">
    </div>
    <button class="layui-btn" lay-submit lay-filter="formDemo">查询</button>
    <button class="layui-btn" lay-submit>清空</button>
</form>
<table class="layui-hide" id="dataList" lay-filter="dataList"></table>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看详情</a>
</script>

<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<script>
    var configureCom = {};
    layui.use(['jquery', 'configureCom', 'configure', 'sessionFun', 'table', 'matchDict'], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var table = layui.table;
        var sessionFun = layui.sessionFun;
        var matchDict = layui.matchDict;

        configureCom = layui.configureCom;
        var cols = [[
            {
                field: 'prjName', title: '建设项目名称', templet: function (d) {
                    return '<p>' + d.prjName + '</p><p>项目编号:' + (d.prjCode || '-') + '</p>';
                }
            },
            {field: 'procDefName', title: '当前阶段'},
            {field: 'createTime', title: '当前阶段办理计时'},
            {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 250}
        ]];
        configureCom.tableRender(configure.PROJECT_COMPLETE_LIST_HTTP, {}, cols, 'dataList', 10, 'full-200');
        //每行操作
        table.on('tool(dataList)', function (obj) {
            var data = obj.data;
            sessionFun.set(configure.SESSION_PROJECT_LIST_DATA, data);
            if (obj.event === 'detail') {
                editItems('详情', configure.UNIT_PROJECT_DETAIL_HTML);
            }else{

            }

        });

        //新增或修改字典详情
        function editItem(title,url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                content: configureCom.nocache(configure.UNIT_PROJECT_DETAIL_HTML),
                btn: ['保存'],
                yes: function (index, layero) {
                    var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    var data = iframeWin.getData().then(function (res) {
                        console.log(res);
                        configureCom.postDataAjax(url, res.result).then(function (res) {
                            console.log(res);
                            top.layer.close(index);
                            top.layer.msg('保存成功！');
                            configureCom.tableReload(true);
                        });
                    });
                },
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }
        //查看详情字典详情
        function editItems(title,url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                content: configureCom.nocache(configure.UNIT_PROJECT_PROHIBITED_DETAIL_HTML),
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }

        //监听搜索
        configureCom.tableSearch();
    });
</script>
</body>
</html>